import React from "react";
import { Input, Button } from "antd";
import { addmess } from "../../../http/postArr";
class Firstshop {
  constructor(name) {
    this.name = name;
  }
  dayin() {
    return "我叫" + this.name + "WDNMD";
  }
}
Firstshop.prototype.say = params => {
  return params;
};

class Secondshop extends Firstshop {
  constructor(props) {
    super(props);
    console.log(this);
  }
}

let sec = new Secondshop();
console.log(sec);
class Addshop extends React.Component {
  constructor(props) {
    // console.log(props,this);
    super(props);
    this.state = {
      postObj: {
        brand: "A"
      },
      mess: {
        name: "111111",
        pas: "222"
      }
    };
    this.addmess = this.addmess.bind(this);
    this.name_change = this.name_change.bind(this);
  }
  render() {
    return (
      <div>
        {this.state.postObj.brand}
        <Input type="text" onChange={this.name_change} />
        <Input.Password value={this.state.mess.pas} />
        <Button onClick={this.addmess}>ADD</Button>
      </div>
    );
  }
  addmess() {
    let post = {
      title: this.state.mess.name,
      contect: this.state.mess.pas
    };
    addmess(post)
      .then(res => {
        console.log(res);
      })
      .catch(err => {
        console.log(err);
      });
  }
  name_change(e) {
    this.setState({
      mess: {
        name: e.currentTarget.value,
        pas: this.state.mess.pas
      }
    });
  }
}
export default Addshop;
